<?php

use App\Http\Controllers\Api\AccountController;
use App\Http\Controllers\Api\CourseTypeController;
use App\Http\Controllers\Api\SubjectController;
use App\Http\Controllers\Api\UploadController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['prefix' => 'api'], function () {
    // 账号相关
    Route::group(['prefix' => 'account'], function () {
        // 登录
        Route::post('wxLogin', [AccountController::class, 'wxLogin']);
        // 刷新token
        Route::post('refreshToken', [AccountController::class, 'refreshToken']);
    });

    // 账号相关
    Route::group(['prefix' => 'upload'], function () {
        // 登录
        Route::post('uploadFiles', [UploadController::class, 'upload']);
    });


    // 科目
    Route::get('subject/list', [SubjectController::class, 'list']);
    Route::get('course/list', [CourseTypeController::class, 'list']);
    Route::get('course/detail', [CourseTypeController::class, 'detail']);
    Route::get('question/detail', [CourseTypeController::class, 'questionDetail']);

    Route::group(['middleware' => 'checkToken'], function () {
        //用户
        Route::put('account/setUserInfo', [AccountController::class, 'setUserInfo']);
        Route::get('account/getUserInfo', [AccountController::class, 'getUserInfo']);
        Route::post('account/clearHistory', [AccountController::class, 'clearHistory']);
        Route::post('account/getHistoryList', [AccountController::class, 'getHistoryList']);
        Route::post('account/saveHistory', [AccountController::class, 'saveHistory']);

        //评论
        Route::post('account/addComment', [AccountController::class, 'addComment']);
        //评论列表
        Route::get('account/getCommentList', [AccountController::class, 'getCommentList']);
        // 点赞
        Route::post('account/toggleLike', [AccountController::class, 'toggleLike']);
        // 获取点赞
        Route::post('account/getLikeInfo', [AccountController::class, 'getLikeInfo']);
        
        // 收藏相关
        Route::post('account/addFavorite', [AccountController::class, 'addFavorite']);
        Route::post('account/removeFavorite', [AccountController::class, 'removeFavorite']);
        Route::get('account/getFavoriteList', [AccountController::class, 'getFavoriteList']);
        Route::get('account/checkFavorite', [AccountController::class, 'checkFavorite']);
    });
});
